package com.hundsun.cprs.yyt.common.base;

/**
 * DAO基类。
 *
 */
public class BaseDao {

	/*@Autowired
	private SqlMapClientTemplate sqlMapClientTemplate;
	protected Log log = LogFactory.getLog(this.getClass());

	*//**
	 * 根据分页条件获取分页信息，其中page参数目前默认采用SimplePage或其子类。
	 * 
	 * @param <T>
	 * @param <T>
	 * @param page
	 *            分页信息
	 * @param qTotalCount
	 *            查询总页数的SQL
	 * @param qPagination
	 *            查询分页的SQL
	 *//*
	public final <T> void paginate(Paginable<T> page, String qTotalCount, String qPagination) {
		if (!(page instanceof SimplePage)) {
			throw new IllegalArgumentException("'page' argument is unsupport class type, " + "it must be "
					+ SimplePage.class.getName() + " or subclass");
		}
		int totalCount = (Integer) getSqlMapClientTemplate().queryForObject(qTotalCount, page);

		SimplePage<T> _page = (SimplePage<T>) page;

		if (totalCount > 0) {
			_page.setTotalCount(totalCount);
			_page.setData(this.getSqlMapClientTemplate().queryForList(qPagination, page));
		} else {
			_page.setData(new ArrayList());
		}
	}

	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	*//**
	 * 对数组进行批量删除操作
	 * 
	 * @param <E>
	 * @param statementName
	 *            对应sqlmap文件的的id
	 * @param list
	 *            需要插入的对象数组
	 *//*
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public <E> void batchInsert(final String statementName, final List<E> list) {
		try {
			if (list != null) {
				this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
					public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
						executor.startBatch();
						for (int i = 0, n = list.size(); i < n; i++) {
							executor.insert(statementName, list.get(i));
						}
						executor.executeBatch();
						return null;
					}
				});
			}
		} catch (Exception e) {
			if (log.isDebugEnabled()) {
				e.printStackTrace();
				log.debug("batchInsert error: id [" + statementName + "], parameterObject [" + list + "].  Cause: "
						+ e.getMessage());
			}
			throw new RuntimeException(e);
		}
	}

	*//**
	 * 批量更新操作
	 * 
	 * @param statementName
	 *            对应sqlmap文件的的id
	 * @param list
	 *            需要更新的对象数组
	 *//*
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void batchUpdate(final String statementName, final List list) {
		try {
			if (list != null) {
				this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
					public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
						executor.startBatch();
						for (int i = 0, n = list.size(); i < n; i++) {
							executor.update(statementName, list.get(i));
						}
						executor.executeBatch();
						return null;
					}
				});
			}
		} catch (Exception e) {
			if (log.isDebugEnabled()) {
				e.printStackTrace();
				log.debug("batchUpdate error: id [" + statementName + "], parameterObject [" + list + "].  Cause: "
						+ e.getMessage());
			}
			throw new RuntimeException(e);
		}

	}

	*//**
	 * 批量删除操作
	 * 
	 * @param statementName
	 *            对应sqlmap文件的的id
	 * @param list
	 *            需要删除的对象数组
	 *//*
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void batchDelete(final String statementName, final List list) {
		try {
			if (list != null) {
				this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
					public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
						executor.startBatch();
						for (int i = 0, n = list.size(); i < n; i++) {
							executor.delete(statementName, list.get(i));
						}
						executor.executeBatch();
						return null;
					}
				});
			}
		} catch (Exception e) {
			if (log.isDebugEnabled()) {
				e.printStackTrace();
				log.debug("batchDelete error: id [" + statementName + "], parameterObject [" + list + "].  Cause: "
						+ e.getMessage());
			}
			throw new RuntimeException(e);
		}
	}

	@Override
	public <T> Paginable<T> getPagination(Paginable<T> page, String qTotalCount, String qPagination) {

		if (!(page instanceof SimplePage)) {
			throw new IllegalArgumentException("'page' argument is unsupport class type, " + "it must be "
					+ SimplePage.class.getName() + " or subclass");
		}
		int totalCount = (Integer) this.getSqlMapClientTemplate().queryForObject(qTotalCount, page);
		if (totalCount > 0) {
			SimplePage<T> _page = (SimplePage<T>) page;
			_page.setTotalCount(totalCount);
			_page.setData(this.getSqlMapClientTemplate().queryForList(qPagination, page));
		}
		return page;

	}*/
}
